#ifndef CHATWINDOW_H
#define CHATWINDOW_H

#include <QMainWindow>
#include <QString>

// 前向声明网络类
class QNetworkAccessManager;
class QNetworkReply;
class QVBoxLayout;
class QHBoxLayout;
class QScrollArea;
class QLineEdit;
class QPushButton;
class QLabel;
class QWidget;

class ChatWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit ChatWindow(QWidget *parent = nullptr);
    ~ChatWindow();

public slots:
    void onSendClicked();
    void onApiReplyFinished(QNetworkReply *reply);
    void onClearChat();
    void onAbout();
    void setApiKey();

private:
    void setupUI();
    void createMenu();
    void setupNetworking();
    void addMessage(const QString &message, bool isAI);
    void callDeepSeekAPI(const QString &message);
    void showThinkingIndicator(bool show);
    void loadSettings();
    void saveSettings();

    QWidget *m_centralWidget;
    QVBoxLayout *m_mainLayout;
    QScrollArea *m_scrollArea;
    QWidget *m_messagesWidget;
    QVBoxLayout *m_messagesLayout;
    QHBoxLayout *m_inputLayout;
    QLineEdit *m_inputField;
    QPushButton *m_sendButton;
    QPushButton *m_clearButton;
    QNetworkAccessManager *m_networkManager;
    QLabel *m_thinkingLabel;
    QString m_apiKey;
};

#endif // CHATWINDOW_H
